<%@page import="com.Cart"%>
<%@page import="java.util.ArrayList"%>


<table border="1" cellspacing="0">
            <thead>
                <tr>
                    <th>No</th>
                    <th>Book ID</th>
                    <th>Title</th>
                    <th>Image</th>
                    <th>Author</th>
                    <th>Type</th>
                    <th>Price</th>
                    <th>Total/Item</th>
                </tr>
            </thead>
            <tbody>
        <%
            session = request.getSession();
            ArrayList<Cart> selectedItems = ( ArrayList<Cart>)session.getAttribute("selectedItems");
            if(selectedItems.size() != 0) {
            int index = 0;
            float totalPayment = 0;
            for(Cart item : selectedItems) {
                index++;
                int id = item.getId();
                String title = item.getTitle();
                String author = item.getAuthor();
                String image = item.getImage();
                String type = item.getType();
                float price = item.getPrice();
                int numItems = item.getNumItem();
                totalPayment = totalPayment + numItems*price;
        %>

                <tr>
                    <td><%= index%></td>
                    <td><%= id %></td>
                    <td><%= title %></td>
                    <td><img src="images/<%= image %>" alt="Images Description for <%= title %>" /></td>
                    <td><%= author %></td>
                    <td><%= type %></td>
                    <td><%= numItems %></td>
                    <td><%=price %></td>
                    <td><%= price*numItems %></td>

                </tr>
                <% } %>
                <tr>
                    <td colspan="5">
                        There are : <strong><%= selectedItems.size() %> in your shopping cart!</strong>
                    </td>
                    <td colspan="3">
                        <strong>Total payment: </strong> <%= totalPayment %>
                    </td>
                </tr>
               <% } else {%>

                        <tr><td colspan="7"><h3>Your cart is empty! </h3></tr>

                <% }

                %>
            </tbody>
        </table>
